package com.qianxun.module.datasource1.develop.manager;

import com.qianxun.module.datasource1.develop.entity.SysFunction;
import com.qianxun.module.datasource1.develop.service.SysFunctionService;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

/**
 * 系统功能缓存管理
 * @author: huwei
 * @date: 2019/12/2 16:32
 * @version: 1.0.0
 */
@Component
@CacheConfig(cacheNames = {"functions"})
public class SysFunctionCacheManager {
    @Resource
    private SysFunctionService sysFunctionService;

    @Cacheable(key = "#root.targetClass.getName() + methodName + '_all_functions'")
    public List<SysFunction> listAll(){
        return sysFunctionService.list();
    }

    @CacheEvict(allEntries = true)
    public void updateBatchByIds(List<SysFunction> list){
        sysFunctionService.updateBatchById(list);
    }
}
